def length(p,g):
    if len(p) > 8:
        g += 1
        return g
    else:
        print("此密码不符合要求，密码长度必须超过8位")
        return 0

def variety(p,g):
    lst = list(p)
    u = 0
    l = 0
    d = 0
    o = 0
    for i in lst:
        if i.isupper():
            u += 1
        elif i.islower():
            l += 1
        elif i.isdigit():
            d += 1
        else:
            o +=1
    if u > 0 and l > 0 and d > 0 and o > 0:
        g += 1
        return g
    elif u > 0 and l > 0 and d > 0 and o == 0:
        g += 1
        return g
    elif u > 0 and l > 0 and d == 0 and o > 0:
        g += 1
        return g
    elif u > 0 and l == 0 and d > 0 and o > 0:
        g += 1
        return g
    elif u == 0 and l > 0 and d > 0 and o > 0:
        g += 1
        return g
    else:
        return 0

def repetition(p,g):
    lst = list(p)
    i = 0
    j = g
    while i < len(lst)-4:
        str = lst[i:i+3]
        if str not in lst[i+3:]:
            g += 1
            break
        i += 1
    if g > j:
        return g
    else:
        return 0

passwd = input("请输入密码：")
grade = 2
advice = []

if length(passwd,grade):
    grade = length(passwd,grade)
else:
    advice.append("长度小于8")

if variety(passwd,grade):
    grade = variety(passwd,grade)
else:
    advice.append("密码没有由3种以上的字符组成")

if repetition(passwd,grade):
    grade = repetition(passwd,grade)
else:
    advice.append("有长度超过或等于3的子串重复")

print(f"评分等级{grade}")
if len(advice) > 0:
    print(advice)










